// 转化时间戳
export const datatamp = (time) => {
	let date = new Date(time);
	return date.getTime();
}
// 时间戳转化为时间 
export const timestampToTime_S = (timestamp) => {
	var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + "-";
	var M =
		(date.getMonth() + 1 < 10 ?
			"0" + (date.getMonth() + 1) :
			date.getMonth() + 1) + "-";
	var D = date.getDate() + " ";
	var h = date.getHours() + ":";
	var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return Y + M + D + h + m + ":" + s;
}
// 时间戳转化为时间 到分钟
export const timestampToTime_M = (timestamp) => {
	var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + "-";
	var M =
		(date.getMonth() + 1 < 10 ?
			"0" + (date.getMonth() + 1) :
			date.getMonth() + 1) + "-";
	var D = date.getDate() + " ";
	var h = date.getHours() + ":";
	var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
	var s = date.getSeconds();
	return Y + M + D + h + m;
}

// 时间戳转化为时间 到日
export const timestampToTime_D = (timestamp) => {
	var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + "/";
	var M =
		(date.getMonth() + 1 < 10 ?
			"0" + (date.getMonth() + 1) :
			date.getMonth() + 1) + "/";
	var D = date.getDate()

	return Y + M + D
}
// 获取当前时间标准格式
export const getnow = (timestamp) => {

	function conver(s) {
		return s < 10 ? "0" + s : s;
	}

	var myDate = new Date();
	//获取当前年
	var year = myDate.getFullYear();
	//获取当前月
	var month = myDate.getMonth() + 1;
	//获取当前日
	var date = myDate.getDate();
	var h = myDate.getHours(); //获取当前小时数(0-23)
	var m = myDate.getMinutes(); //获取当前分钟数(0-59)
	var s = myDate.getSeconds();
	//获取当前时间
	return (
		year +
		"-" +
		conver(month) +
		"-" +
		conver(date) +
		" " +
		conver(h) +
		":" +
		conver(m) +
		":" +
		conver(s)
	);
}